from abaqusConstants import *
import abaqus_functions
abaqus_functions = reload( abaqus_functions)
#abaqus_functions.configure_session( session )
#import visualization
#odbpath = session.odbs.keys()[0]
#odb = visualization.openOdb( path=odbpath )
#odbpath = 'C:/Temp/abaqus/zimmermann_h_effect_r_100_h_100_a00_numel_r_080/outputs/r_100_h_100_2_Steps_pt_050_PLvalue_0000.odb'
#odb = visualization.openOdb(path=odbpath)
##myview = session.Viewport(name='testing',origin=(0,0),width=570,height=1256)
#myview = session.viewports['Viewport: 1']
#myview.setValues(displayedObject=odb)
#myview.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
#myview.odbDisplay.setFrame(step=1,frame=0)
#myview.odbDisplay.contourOptions.setValues( numIntervals=10,
#    maxAutoCompute=ON, maxValue=0.10,
#    minAutoCompute=ON, minValue=0.00, )
#session.printOptions.setValues( rendition=COLOR,
#    vpDecorations=OFF, vpBackground=OFF )
plot_names = session.xyDataObjects.keys()
if not 'XYPlot-1' in session.xyPlots.keys():
    xyp = session.XYPlot('XYPlot-1')
else:
    xyp = session.xyPlots['XYPlot-1']
myv = session.viewports['Viewport: 1'] 
myv.restore()
myv.setValues(
               displayedObject=xyp,
               width  = 653.04,
               height = 297.04,

             )
myv.maximize()
for name in plot_names:
    c = session.Curve(xyData=session.xyDataObjects[name])
    chart = session.xyPlots['XYPlot-1'].charts['Chart-1']
    chart.setValues(curvesToPlot=(c,))
    if name.find('PL_CURVE') > -1:
        chart.legend.setValues(show=False)
    else:
        chart.legend.setValues(show=False)
        chart.legend.setValues(show=True)
    session.printToFile( fileName = name, format=PNG,
                         canvasObjects=(myv,))
